package GUI;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author Tim
 */
public class Kaart extends JPanel
{
    /**
     *
     */
    public static final int CLUBS = 0;
    /**
     *
     */
    public static final int SPADES = 1;
    /**
     *
     */
    public static final int HEARTS = 2;
    /**
     *
     */
    public static final int DIAMONDS = 3;

    /**
     *
     */
    public static final int cardWidth = 72;
    /**
     *
     */
    public static final int cardHeight = 96;

    private static final int marginTop = 10;
    private static final int marginLeft = 10;

    private static final String cardFolder = "src/GUI/classic-cards";

    private BufferedImage image;

    private int suit, value, top, left;

    /**
     *
     * @param suit
     * @param value
     */
    public Kaart(int suit, int value) {
        this.value = value;
        this.suit = suit;

        String imageName = cardFolder + "/"+suit+value+".png";
        File input = new File(imageName);
        try {
            image = ImageIO.read(input);
        } catch (IOException ioe) {
           System.err.println(ioe.getMessage());
        }
    }

    /**
     *
     * @param suit
     * @param value
     * @param hidden
     */
    public Kaart(int suit, int value, boolean hidden) {
        
        this.value = value;
        this.suit = suit;
        String imageName = "";
        if(!hidden) {
            imageName = cardFolder + "/999.png";
        } else {
            imageName = cardFolder + "/"+suit+value+".png";
        }
        File input = new File(imageName);
        try {
            image = ImageIO.read(input);
        } catch (IOException ioe) {
           System.err.println(ioe.getMessage());
        }
    }

    public void paint(Graphics g) {
        g.drawImage(image, 0, 0, cardWidth, cardHeight, null);
      }

    public void paintComponent(Graphics g)
    {

    }
}